package com.dycx.system.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * @author 地区级别
 * @date 2023/2/23
 */
@Getter
public enum RegionLevelEnum {
    PROVINCE("province", "省"),
    CITY("city", "市"),
    DISTRICT("district", "区"),
    STREET("street", "街道");

    private final String code;
    private final String name;

    RegionLevelEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String converter(String code) {
        return Arrays.stream(values()).filter(en -> en.code.equals(code)).findAny().orElse(PROVINCE).getName();
    }
}
